package com.xingkeduo.dto.param;

import com.alibaba.fastjson.JSON;
import com.xingkeduo.pojo.enums.OrderSource;
import com.xingkeduo.pojo.enums.ServiceType;
import com.xingkeduo.utils.TableAnnotations;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.Map;

/**
 *
 * @author chi  2019-02-14 16:58
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class OrderInitDto {


    private String storeId;

    private String userId;

    @NotBlank(message = "预约发型师id不能为空")
    @TableAnnotations("预约发型师id")
    private String appointmentAdminId;
    @TableAnnotations("预约发型师name")
    private String appointmentAdminName;

    private BigDecimal allPrice;


    @TableAnnotations("预约开始时间")
    private String appointmentStartTime;

    @TableAnnotations("预约结束时间")
    private String appointmentEndTime;

    @TableAnnotations("服务类型 1剪发 2刘海 3高级")
    private ServiceType serviceType;

    @TableAnnotations("订单来源")
    private OrderSource orderSource;

    //优惠标识 1优惠券 2会员卡
    private int marketingType;

    //卡券详情
    private String cardCouponDetail;

    //活动类型
    private String activityType;

    //活动详情
    private String activityDetail;

    @TableAnnotations("库存id")
    private String appointmentId;

    //服务类型
    private String serviceTypeId;


    public void covert(OrderAddParameterDto orderAddParameterDto, String adminName, Map<String,Object> map) {
        this.allPrice=null;
        this.appointmentAdminId = orderAddParameterDto.getAdmin_id();
        this.appointmentAdminName = adminName;
        this.appointmentEndTime=map.get("endTime")+"";
        this.appointmentId = String.valueOf(map.get("id"));
        this.appointmentStartTime=map.get("startTime")+"";
        this.serviceType =ServiceType.getEnum(orderAddParameterDto.getService_type());
        this.storeId = orderAddParameterDto.getStore_id();
        this.userId = orderAddParameterDto.getF_user_id();
        this.serviceTypeId= orderAddParameterDto.getService_type()+"";

        String mobile_type = orderAddParameterDto.getMobile_type();
        int selected_ticket_type=orderAddParameterDto.getSelected_ticket_type();

        this.orderSource = OrderSource.WECHAT;

        if("alipay".equals(mobile_type)){
            if(selected_ticket_type==1){
                this.orderSource = OrderSource.ALIPAY_SCAN;
            }
            if(selected_ticket_type==3){
                this.orderSource = OrderSource.ALIPAY;
            }
        }

        if("wechat".equals(mobile_type)){
            if(selected_ticket_type==1){
                this.orderSource = OrderSource.BRANCH;
            }
            if(selected_ticket_type==3){
                this.orderSource = OrderSource.WECHAT_H5;
            }
        }




    }
}
